Skip to content

fix(forms): add directives for formControl #861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2017

Conversation

zbarbuto
Copy link
Contributor

Somewhat related to #576 and #526

At the moment, selectors only apply to ngModel and formControlName meaning for Angular reactive forms to work with inputs, they must use formControlName within a formGroup directive.

I would like to add [formControl] to the list of selectors so that reactive forms can be used without a parent formGroup.

Rationale:
Say you have a dumb component which implements an input:

@Component({
  selector: 'my-custom-input',
  template: `<TextField [formControl]="control">`
})
export class MyCustomInput {
  @Input() control: FormControl
}

Which is used by some parent component:

@Component({
  selector: 'my-parent-component',
  template: `<my-custom-input [control]="formGroup.get('someControl')"`
})
export class MyCustomInput {
  public formGroup: FormGroup;
  constructor() {
    this.formGroup = new FormGroup({ someControl: new FormControl('') })
  }
}

The above does not work with the latest nativescript-angular with the following error: "No value accessor for form control with unspecified name attribute".

Adding the directives in the PR makes the above example work.

@ns-bot
Copy link

ns-bot commented Jun 23, 2017

Can one of the admins verify this patch?

2 similar comments
@ns-bot
Copy link

ns-bot commented Jun 23, 2017

Can one of the admins verify this patch?

@ns-bot
Copy link

ns-bot commented Jun 23, 2017

Can one of the admins verify this patch?

@sis0k0
Copy link
Contributor

sis0k0 commented Jun 23, 2017

run ci

Copy link
Contributor

@sis0k0 sis0k0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sis0k0 sis0k0 changed the title Add directives for formControl fix(forms): add directives for formControl Jun 23, 2017
@sis0k0 sis0k0 merged commit bd38745 into NativeScript:master Jun 23, 2017
sis0k0 added a commit that referenced this pull request Jun 23, 2017
@zbarbuto
Copy link
Contributor Author

Thanks for merging so quickly.

Any idea when the next release is scheduled? Need this functionality for a project I am currently working on.

@sis0k0
Copy link
Contributor

sis0k0 commented Jun 29, 2017

Heya, the fix is available when using the next tag. We'll release it officially with 3.1.1 (probably in a few hours :) )

@jlooper
Copy link

jlooper commented Jun 29, 2017

Congratulations! This PR was so awesome that it earned you a badge!
contrib
Ping me on NativeScript Community Slack and I'll send you a t-shirt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants